clear 

** read in .dta file **

use "${clean}/who_counts_analysis.dta", clear

** Coefficient plot, Alt. Dichotimization, 1945-1962 **

** Regressions **

* Dummy specification: BW1, 1945-1955 **

xi: reghdfe MOB did_ANY Arabic Female *_itTREATED *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW2_any

xi: reghdfe Schooling did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW2_any

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW2_any

xi: reghdfe French_Lit did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW2_any

* Max specification: BW2, 1945-1962

xi: reghdfe MOB did_max Arabic Female *_itTREATED *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW2_max

xi: reghdfe EDU_YRS did_edu_max Arabic Female *_itTREATEDEDU *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW2_max

xi: reghdfe Schooling did_edu_max Arabic Female *_itTREATEDEDU *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_Schooling_did_BW2_max

xi: reghdfe French_Lit did_edu_max Arabic Female *_itTREATEDEDU *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_Lit_did_BW2_max


drop if YOB > 1955

** Main specification **

xi: reghdfe MOB did_ANY Arabic Female *_itTREATED *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW1_any
estimates store m_MOB_did_BW1_any

xi: reghdfe Schooling did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW1_any

xi: reghdfe French_Lit did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW1_any

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW1_any

* Max specification: BW1, 1945-1955 **

xi: reghdfe MOB did_max Arabic Female *_itTREATED *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW1_max

xi: reghdfe EDU_YRS did_edu_max Arabic Female *_itTREATEDEDU *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW1_max

xi: reghdfe Schooling did_edu_max Arabic Female *_itTREATEDEDU *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_Schooling_did_BW1_max

xi: reghdfe French_Lit did_edu_max Arabic Female *_itTREATEDEDU *_itFORMAX, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_Lit_did_BW1_max

** Output Graphs **

* Change labels for space
label variable did_ANY "DiD"
label variable did_edu_ANY "DiD"

label variable did_max "DiD, Alt"
label variable did_edu_max "DiD, Alt"

* Plots

coefplot (m_MOB_did_BW1_any, label(1945-1955)) (m_MOB_did_BW1_max, label(1945-1955, Alt)) (m_MOB_did_BW2_any, label(1945-1962)) (m_MOB_did_BW2_max, label(1945-1962, Alt)), keep(did_ANY did_max) vertical yline(0) title("Registration") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/MOB_max.gph", replace

coefplot (m_School_did_BW1_any, label(1945-1955)) (m_Schooling_did_BW1_max, label(1945-1955, Alt)) (m_School_did_BW2_any, label(1945-1962)) (m_Schooling_did_BW2_max, label(1945-1962, Alt)), keep(did_edu_ANY did_edu_max) vertical yline(0) title("Schooling") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/Schooling_max.gph", replace

coefplot (m_YRS_did_BW1_any, label(1945-1955)) (m_YRS_did_BW1_max, label(1945-1955, Alt)) (m_YRS_did_BW2_any, label(1945-1962)) (m_YRS_did_BW2_max, label(1945-1962, Alt)), keep(did_edu_ANY did_edu_max) vertical yline(0) title("Schooling, Years") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/YRS_max.gph", replace

coefplot (m_LIT_did_BW1_any, label(1945-1955)) (m_Lit_did_BW1_max, label(1945-1955, Alt)) (m_LIT_did_BW2_any, label(1945-1962)) (m_Lit_did_BW2_max, label(1945-1962, Alt)), keep(did_edu_ANY did_edu_max) vertical yline(0) title("Literacy, French") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/LIT_max.gph", replace

grc1leg  "${output}/graphs/MOB_max.gph" "${output}/graphs/Schooling_max.gph" "${output}/graphs/YRS_max.gph" "${output}/graphs/LIT_max.gph",legendfrom("${output}/graphs/Schooling_max.gph")
graph save Graph "${output}/graphs/DiD_max.gph", replace
graph export "${output}/graphs/Figure13A.png", replace

